<template>
	<view class="video-box">
		<video :id="'myvideo'+video._id"  :src="video.src" controls class="myvideo" :autoplay="play" enable-play-gesture='true'></video>
	</view>
</template>

<script>
	export default {
		props:['video','index'],
		name:'myVideo',
		data(){
			return {
				play:false
			}
		},
		created(){
			if(this.index == 0){
				this.play = true
			}
		},
		mounted() {
		  this.videoContext = uni.createVideoContext('myvideo'+this.$props.video._id,this)
		},
		methods:{
			playVideo(){
				this.videoContext.seek(0)
				this.videoContext.play()
			},
			pauseVideo(){
				this.videoContext.pause()
			}
		}
	}
</script>

<style>
	.video-box{
		width: 100%;
		height: 100%;
	}
	.myvideo{
		width: 100%;
		height: 100%;
	}
</style>